package cn.lzd.mr.count.writable;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * 学习：先了解、后深入；先记录、后记忆；先理论、后实践；先模仿、后创新
 * Created by lzd on 2018/5/12.
 */
public class WordCountM extends Mapper<LongWritable, Text, LongWritable, WriteBean> {



    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        System.out.println("-------------------------"+key.get()+"----------------"+value.toString());

        String text = value.toString();
        String[] split = text.split(" ");
        String str = split[0];

        WriteBean bean = new WriteBean();
        bean.setStr(str);
        bean.setStrLength(str.length());

        context.write(key, bean);
    }
}
